package day8;

import java.util.Arrays;

import org.junit.Test;

public class Demo {
	
	public static void main(String[] args) {
		
	}
	
	@Test
	public void test1() {
		// 静态属性的方法通过：类名.属性
		Student.address = "城阳区51号";
		
		Student student1 = new Student();
		student1.id = 2;
		student1.name = "zhangsan";
		//student1.address = "城阳区51号";
		// The static field Student.address should be accessed in a static way
		// 静态属性也可以通过对象.属性访问,但是会报警告，不建议通过这种方式访问静态属性，
		// 因为静态属性时属于这个类的
		student1.address = "青岛";
		student1.study();
		
		Student student2 = new Student();
		student2.id = 3;
		student2.name = "李四";
		//student2.address = "城阳区51号";
		student2.study();
		
		// 静态方法调用  
		Student.show();
		student2.show();
	}
	
	@Test
	public void test3() {
		// 静态的属性和静态方法是属于这个类的，即使现在没有new任何一个对象，只要这个类
		// 加载到内存就可以访问静态属性和静态方法
		Student.address = "青岛";
		Student.print();
		Student.show();
		
	}
	
	@Test
	public void test4() {
		int[] array = {40, 17, 21, 1};
		// Arrays是工具类，这个工具类提供和数组相关的一些操作像排序、打印
		Arrays.sort(array);
		System.out.println(Arrays.toString(array));
		for (int i = 0; i < array.length; i++) {
			System.out.println(array[i]);
		}
		
		int num1 = 3;
		int num2 = 5;
		int m1 = max(num1, num2);
		
		// Math也是一个工具类，封装很多和数学计算相关的静态方法
		int m2 = Math.max(num1, num2);
		// public static final double PI
		// Math.PI;
	}
	
	public int max(int num1, int num2) {
		int max = 0;
		if (num1 > num2) {
			max =  num1;
		} else {
			max = num2;
		}
		return max;
	}
	
	@Test
	public void test44() {
		int[] array = {40, 17, 21, 1};
		int max = ArrayUtil.max(array);
		System.out.println(max);
		
		ArrayUtil util = new ArrayUtil();
		max = util.max(array);
		System.out.println(max);
	}
	
	@Test
	public void test5() {
		Teacher teacher1 = new Teacher();
		Teacher teacher2 = new Teacher();
	}
}
